<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html><head><title>QAbstractTextDocumentLayout Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
td.postheader { font-family: sans-serif }
tr.address { font-family: sans-serif }
body { background: #ffffff; color: black; }
</style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">&#160;&#160;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&#160;&#183; <a href="classes.html"><font color="#004faf">All Classes</font></a>&#160;&#183; <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QAbstractTextDocumentLayout Class Reference<br /><sup><sup>[<a href="qtgui.html">QtGui</a> module]</sup></sup></h1><p>The QAbstractTextDocumentLayout class is an abstract base class
used to implement custom layouts for QTextDocuments. <a href="#details">More...</a></p>

<p>Inherits <a href="qobject.html">QObject</a>.</p><p>Inherited by <a href="qplaintextdocumentlayout.html">QPlainTextDocumentLayout</a>.</p><h3>Types</h3><ul><li><div class="fn" />class <b><a href="qabstracttextdocumentlayout-paintcontext.html">PaintContext</a></b></li><li><div class="fn" />class <b><a href="qabstracttextdocumentlayout-selection.html">Selection</a></b></li></ul><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qabstracttextdocumentlayout.html#QAbstractTextDocumentLayout">__init__</a></b> (<i>self</i>, QTextDocument&#160;<i>doc</i>)</li><li><div class="fn" />QString <b><a href="qabstracttextdocumentlayout.html#anchorAt">anchorAt</a></b> (<i>self</i>, QPointF&#160;<i>pos</i>)</li><li><div class="fn" />QRectF <b><a href="qabstracttextdocumentlayout.html#blockBoundingRect">blockBoundingRect</a></b> (<i>self</i>, QTextBlock&#160;<i>block</i>)</li><li><div class="fn" />QTextDocument <b><a href="qabstracttextdocumentlayout.html#document">document</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qabstracttextdocumentlayout.html#documentChanged">documentChanged</a></b> (<i>self</i>, int&#160;<i>from</i>, int&#160;<i>charsRemoved</i>, int&#160;<i>charsAdded</i>)</li><li><div class="fn" />QSizeF <b><a href="qabstracttextdocumentlayout.html#documentSize">documentSize</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qabstracttextdocumentlayout.html#draw">draw</a></b> (<i>self</i>, QPainter&#160;<i>painter</i>, PaintContext&#160;<i>context</i>)</li><li><div class="fn" /><b><a href="qabstracttextdocumentlayout.html#drawInlineObject">drawInlineObject</a></b> (<i>self</i>, QPainter&#160;<i>painter</i>, QRectF&#160;<i>rect</i>, QTextInlineObject&#160;<i>object</i>, int&#160;<i>posInDocument</i>, QTextFormat&#160;<i>format</i>)</li><li><div class="fn" />QTextCharFormat <b><a href="qabstracttextdocumentlayout.html#format">format</a></b> (<i>self</i>, int&#160;<i>pos</i>)</li><li><div class="fn" />QRectF <b><a href="qabstracttextdocumentlayout.html#frameBoundingRect">frameBoundingRect</a></b> (<i>self</i>, QTextFrame&#160;<i>frame</i>)</li><li><div class="fn" />QTextObjectInterface <b><a href="qabstracttextdocumentlayout.html#handlerForObject">handlerForObject</a></b> (<i>self</i>, int&#160;<i>objectType</i>)</li><li><div class="fn" />int <b><a href="qabstracttextdocumentlayout.html#hitTest">hitTest</a></b> (<i>self</i>, QPointF&#160;<i>point</i>, Qt.HitTestAccuracy&#160;<i>accuracy</i>)</li><li><div class="fn" />int <b><a href="qabstracttextdocumentlayout.html#pageCount">pageCount</a></b> (<i>self</i>)</li><li><div class="fn" />QPaintDevice <b><a href="qabstracttextdocumentlayout.html#paintDevice">paintDevice</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qabstracttextdocumentlayout.html#positionInlineObject">positionInlineObject</a></b> (<i>self</i>, QTextInlineObject&#160;<i>item</i>, int&#160;<i>posInDocument</i>, QTextFormat&#160;<i>format</i>)</li><li><div class="fn" /><b><a href="qabstracttextdocumentlayout.html#registerHandler">registerHandler</a></b> (<i>self</i>, int&#160;<i>objectType</i>, QObject&#160;<i>component</i>)</li><li><div class="fn" /><b><a href="qabstracttextdocumentlayout.html#resizeInlineObject">resizeInlineObject</a></b> (<i>self</i>, QTextInlineObject&#160;<i>item</i>, int&#160;<i>posInDocument</i>, QTextFormat&#160;<i>format</i>)</li><li><div class="fn" /><b><a href="qabstracttextdocumentlayout.html#setPaintDevice">setPaintDevice</a></b> (<i>self</i>, QPaintDevice&#160;<i>device</i>)</li></ul><h3>Qt Signals</h3><ul><li><div class="fn" />void <b><a href="qabstracttextdocumentlayout.html#documentSizeChanged">documentSizeChanged</a></b> (const QSizeF&amp;)</li><li><div class="fn" />void <b><a href="qabstracttextdocumentlayout.html#pageCountChanged">pageCountChanged</a></b> (int)</li><li><div class="fn" />void <b><a href="qabstracttextdocumentlayout.html#update">update</a></b> (const QRectF&amp; = QRectF(0,0,1e+09,1e+09))</li><li><div class="fn" />void <b><a href="qabstracttextdocumentlayout.html#updateBlock">updateBlock</a></b> (const QTextBlock&amp;)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QAbstractTextDocumentLayout class is an abstract base class
used to implement custom layouts for QTextDocuments.</p>
<p>The standard layout provided by Qt can handle simple word
processing including inline images, lists and tables.</p>
<p>Some applications, e.g., a word processor or a DTP application
might need more features than the ones provided by Qt's layout
engine, in which case you can subclass QAbstractTextDocumentLayout
to provide custom layout behavior for your text documents.</p>
<p>An instance of the QAbstractTextDocumentLayout subclass can be
installed on a <a href="qtextdocument.html">QTextDocument</a>
object with the <a href="qtextdocument.html#setDocumentLayout">setDocumentLayout()</a>
function.</p>
<p>You can insert custom objects into a <a href="qtextdocument.html">QTextDocument</a>; see the <a href="qtextobjectinterface.html">QTextObjectInterface</a> class
description for details.</p>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QAbstractTextDocumentLayout" />QAbstractTextDocumentLayout.__init__ (<i>self</i>, <a href="qtextdocument.html">QTextDocument</a>&#160;<i>doc</i>)</h3><p>Creates a new text document layout for the given
<i>document</i>.</p>


<h3 class="fn"><a name="anchorAt" />QString QAbstractTextDocumentLayout.anchorAt (<i>self</i>, <a href="qpointf.html">QPointF</a>&#160;<i>pos</i>)</h3><p>Returns the reference of the anchor the given <i>position</i>,
or an empty string if no anchor exists at that point.</p>


<h3 class="fn"><a name="blockBoundingRect" /><a href="qrectf.html">QRectF</a> QAbstractTextDocumentLayout.blockBoundingRect (<i>self</i>, <a href="qtextblock.html">QTextBlock</a>&#160;<i>block</i>)</h3><p>This method is abstract and should be reimplemented in any sub-class.</p><p>Returns the bounding rectangle of <i>block</i>.</p>


<h3 class="fn"><a name="document" /><a href="qtextdocument.html">QTextDocument</a> QAbstractTextDocumentLayout.document (<i>self</i>)</h3><p>Returns the text document that this layout is operating on.</p>


<h3 class="fn"><a name="documentChanged" />QAbstractTextDocumentLayout.documentChanged (<i>self</i>, int&#160;<i>from</i>, int&#160;<i>charsRemoved</i>, int&#160;<i>charsAdded</i>)</h3><p>This method is abstract and should be reimplemented in any sub-class.</p><p>This function is called whenever the contents of the document
change. A change occurs when text is inserted, removed, or a
combination of these two. The change is specified by
<i>position</i>, <i>charsRemoved</i>, and <i>charsAdded</i>
corresponding to the starting character position of the change, the
number of characters removed from the document, and the number of
characters added.</p>
<p>For example, when inserting the text "Hello" into an empty
document, <i>charsRemoved</i> would be 0 and <i>charsAdded</i>
would be 5 (the length of the string).</p>
<p>Replacing text is a combination of removing and inserting. For
example, if the text "Hello" gets replaced by "Hi",
<i>charsRemoved</i> would be 5 and <i>charsAdded</i> would be
2.</p>
<p>For subclasses of <a href="qabstracttextdocumentlayout.html">QAbstractTextDocumentLayout</a>,
this is the central function where a large portion of the work to
lay out and position document contents is done.</p>
<p>For example, in a subclass that only arranges blocks of text, an
implementation of this function would have to do the following:</p>
<ul>
<li>Determine the list of changed <a href="qtextblock.html">QTextBlock</a>(s) using the parameters
provided.</li>
<li>Each <a href="qtextblock.html">QTextBlock</a> object's
corresponding <a href="qtextlayout.html">QTextLayout</a> object
needs to be processed. You can access the <a href="qtextblock.html">QTextBlock</a>'s layout using the <a href="qtextblock.html#layout">QTextBlock.layout</a>() function. This
processing should take the document's page size into
consideration.</li>
<li>If the total number of pages changed, the <a href="qabstracttextdocumentlayout.html#pageCountChanged">pageCountChanged</a>()
signal should be emitted.</li>
<li>If the total size changed, the <a href="qabstracttextdocumentlayout.html#documentSizeChanged">documentSizeChanged</a>()
signal should be emitted.</li>
<li>The <a href="qabstracttextdocumentlayout.html#update">update</a>() signal
should be emitted to schedule a repaint of areas in the layout that
require repainting.</li>
</ul>
<p><b>See also</b> <a href="qtextlayout.html">QTextLayout</a>.</p>


<h3 class="fn"><a name="documentSize" /><a href="qsizef.html">QSizeF</a> QAbstractTextDocumentLayout.documentSize (<i>self</i>)</h3><p>This method is abstract and should be reimplemented in any sub-class.</p><p>Returns the total size of the document's layout.</p>
<p>This information can be used by display widgets to update their
scroll bars correctly.</p>
<p><b>See also</b> <a href="qabstracttextdocumentlayout.html#documentSizeChanged">documentSizeChanged</a>()
and <a href="qtextdocument.html#pageSize-prop">QTextDocument.pageSize</a>.</p>


<h3 class="fn"><a name="draw" />QAbstractTextDocumentLayout.draw (<i>self</i>, <a href="qpainter.html">QPainter</a>&#160;<i>painter</i>, <a href="qabstracttextdocumentlayout-paintcontext.html">PaintContext</a>&#160;<i>context</i>)</h3><p>This method is abstract and should be reimplemented in any sub-class.</p><p>Draws the layout with the given <i>painter</i> using the given
<i>context</i>.</p>


<h3 class="fn"><a name="drawInlineObject" />QAbstractTextDocumentLayout.drawInlineObject (<i>self</i>, <a href="qpainter.html">QPainter</a>&#160;<i>painter</i>, <a href="qrectf.html">QRectF</a>&#160;<i>rect</i>, <a href="qtextinlineobject.html">QTextInlineObject</a>&#160;<i>object</i>, int&#160;<i>posInDocument</i>, <a href="qtextformat.html">QTextFormat</a>&#160;<i>format</i>)</h3><p>This function is called to draw the inline object,
<i>object</i>, with the given <i>painter</i> within the rectangle
specified by <i>rect</i> using the specified text
<i>format</i>.</p>
<p><i>posInDocument</i> specifies the position of the object within
the document.</p>
<p>The default implementation calls drawObject() on the object
handlers. This function is called only within Qt. Subclasses can
reimplement this function to customize the drawing of inline
objects.</p>
<p><b>See also</b> <a href="qabstracttextdocumentlayout.html#draw">draw</a>().</p>


<h3 class="fn"><a name="format" /><a href="qtextcharformat.html">QTextCharFormat</a> QAbstractTextDocumentLayout.format (<i>self</i>, int&#160;<i>pos</i>)</h3><p>Returns the character format that is applicable at the given
<i>position</i>.</p>


<h3 class="fn"><a name="frameBoundingRect" /><a href="qrectf.html">QRectF</a> QAbstractTextDocumentLayout.frameBoundingRect (<i>self</i>, <a href="qtextframe.html">QTextFrame</a>&#160;<i>frame</i>)</h3><p>This method is abstract and should be reimplemented in any sub-class.</p><p>Returns the bounding rectangle of <i>frame</i>.</p>


<h3 class="fn"><a name="handlerForObject" /><a href="qtextobjectinterface.html">QTextObjectInterface</a> QAbstractTextDocumentLayout.handlerForObject (<i>self</i>, int&#160;<i>objectType</i>)</h3><p>Returns a handler for objects of the given
<i>objectType</i>.</p>


<h3 class="fn"><a name="hitTest" />int QAbstractTextDocumentLayout.hitTest (<i>self</i>, <a href="qpointf.html">QPointF</a>&#160;<i>point</i>, <a href="qt.html#HitTestAccuracy-enum">Qt.HitTestAccuracy</a>&#160;<i>accuracy</i>)</h3><p>This method is abstract and should be reimplemented in any sub-class.</p><p>Returns the cursor postion for the given <i>point</i> with the
specified <i>accuracy</i>. Returns -1 if no valid cursor position
was found.</p>


<h3 class="fn"><a name="pageCount" />int QAbstractTextDocumentLayout.pageCount (<i>self</i>)</h3><p>This method is abstract and should be reimplemented in any sub-class.</p><p>Returns the number of pages contained in the layout.</p>
<p><b>See also</b> <a href="qabstracttextdocumentlayout.html#pageCountChanged">pageCountChanged</a>().</p>


<h3 class="fn"><a name="paintDevice" /><a href="qpaintdevice.html">QPaintDevice</a> QAbstractTextDocumentLayout.paintDevice (<i>self</i>)</h3><p>Returns the paint device used to render the document's
layout.</p>
<p><b>See also</b> <a href="qabstracttextdocumentlayout.html#setPaintDevice">setPaintDevice</a>().</p>


<h3 class="fn"><a name="positionInlineObject" />QAbstractTextDocumentLayout.positionInlineObject (<i>self</i>, <a href="qtextinlineobject.html">QTextInlineObject</a>&#160;<i>item</i>, int&#160;<i>posInDocument</i>, <a href="qtextformat.html">QTextFormat</a>&#160;<i>format</i>)</h3><p>Lays out the inline object <i>item</i> using the given text
<i>format</i>.</p>
<p><i>posInDocument</i> specifies the position of the object within
the document.</p>
<p>The default implementation does nothing. This function is called
only within Qt. Subclasses can reimplement this function to
customize the position of inline objects.</p>
<p><b>See also</b> <a href="qabstracttextdocumentlayout.html#drawInlineObject">drawInlineObject</a>().</p>


<h3 class="fn"><a name="registerHandler" />QAbstractTextDocumentLayout.registerHandler (<i>self</i>, int&#160;<i>objectType</i>, <a href="qobject.html">QObject</a>&#160;<i>component</i>)</h3><p>Registers the given <i>component</i> as a handler for items of
the given <i>objectType</i>.</p>
<p><b>Note:</b> registerHandler() has to be called once for each
object type. This means that there is only one handler for multiple
replacement characters of the same object type.</p>


<h3 class="fn"><a name="resizeInlineObject" />QAbstractTextDocumentLayout.resizeInlineObject (<i>self</i>, <a href="qtextinlineobject.html">QTextInlineObject</a>&#160;<i>item</i>, int&#160;<i>posInDocument</i>, <a href="qtextformat.html">QTextFormat</a>&#160;<i>format</i>)</h3><p>Sets the size of the inline object <i>item</i> corresponding to
the text <i>format</i>.</p>
<p><i>posInDocument</i> specifies the position of the object within
the document.</p>
<p>The default implementation resizes the <i>item</i> to the size
returned by the object handler's intrinsicSize() function. This
function is called only within Qt. Subclasses can reimplement this
function to customize the resizing of inline objects.</p>


<h3 class="fn"><a name="setPaintDevice" />QAbstractTextDocumentLayout.setPaintDevice (<i>self</i>, <a href="qpaintdevice.html">QPaintDevice</a>&#160;<i>device</i>)</h3><p>Sets the paint device used for rendering the document's layout
to the given <i>device</i>.</p>
<p><b>See also</b> <a href="qabstracttextdocumentlayout.html#paintDevice">paintDevice</a>().</p>


<hr /><h2>Qt Signal Documentation</h2><h3 class="fn"><a name="documentSizeChanged" />void documentSizeChanged (const QSizeF&amp;)</h3><p>This is the default overload of this signal.</p><p>This signal is emitted when the size of the document layout
changes to <i>newSize</i>.</p>
<p>Subclasses of <a href="qabstracttextdocumentlayout.html">QAbstractTextDocumentLayout</a>
should emit this signal when the document's entire layout size
changes. This signal is useful for widgets that display text
documents since it enables them to update their scroll bars
correctly.</p>
<p><b>See also</b> <a href="qabstracttextdocumentlayout.html#documentSize">documentSize</a>().</p>


<h3 class="fn"><a name="pageCountChanged" />void pageCountChanged (int)</h3><p>This is the default overload of this signal.</p><p>This signal is emitted when the number of pages in the layout
changes; <i>newPages</i> is the updated page count.</p>
<p>Subclasses of <a href="qabstracttextdocumentlayout.html">QAbstractTextDocumentLayout</a>
should emit this signal when the number of pages in the layout has
changed. Changes to the page count are caused by changes to the
layout or the document content itself.</p>
<p><b>See also</b> <a href="qabstracttextdocumentlayout.html#pageCount">pageCount</a>().</p>


<h3 class="fn"><a name="update" />void update (const QRectF&amp; = QRectF (0,0,1e+09,1e+09))</h3><p>This is the default overload of this signal.</p><p>This signal is emitted when the rectangle <i>rect</i> has been
updated.</p>
<p>Subclasses of <a href="qabstracttextdocumentlayout.html">QAbstractTextDocumentLayout</a>
should emit this signal when the layout of the contents change in
order to repaint.</p>


<h3 class="fn"><a name="updateBlock" />void updateBlock (const QTextBlock&amp;)</h3><p>This is the default overload of this signal.</p><p>This signal is emitted when the specified <i>block</i> has been
updated.</p>
<p>Subclasses of <a href="qabstracttextdocumentlayout.html">QAbstractTextDocumentLayout</a>
should emit this signal when the layout of <i>block</i> has changed
in order to repaint.</p>
<p>This function was introduced in Qt 4.4.</p>
<address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt&#160;snapshot-4.9.5-9eb6aac99275 for X11</td><td align="center" width="50%">Copyright &#169; <a href="http://www.riverbankcomputing.com">Riverbank&#160;Computing&#160;Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2012</td><td align="right" width="25%">Qt&#160;4.8.3</td></tr></table></div></address></body></html>